﻿using MHI.DeviceManager.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebFoundation.Data;

namespace MHI.DeviceManager.Data
{
    internal class DevDevicemaintenanceTQueryDAO : QueriableDAO<DevDevicemaintenanceT>
    {
        protected static DbManager _dbManager = WebFoundation.Data.DbManager.FromConfig("DefaultConnection");

        public DevDevicemaintenanceTQueryDAO()
        : base(_dbManager)
        {
        }

        public DevDevicemaintenanceTQueryDAO(DbManager db)
            : base(db)
        {
        }

        /// <summary>
		/// 获取所有DevDevicemaintenanceT,table items:dev_devicemaintenance_t信息 
		/// </summary>
		/// <returns></returns>
		public IEnumerable<DevDevicemaintenanceT> GetDevDevicemaintenanceTAllItems()
        {
            var query = this.CreateQuery();
            query.Filter().Eq(r => r.IsUse, 1);
            return this.Query(query);
        }

        /// <summary>
        /// 根据设备id获取相应的保养项信息
        /// </summary>
        /// <param name="deviceId"></param>
        /// <returns></returns>
        public IEnumerable<DevDevicemaintenanceT> GetMaintenanceItemsById(int deviceId)
        {
            var query = this.CreateQuery();
            query.Filter().Eq(r => r.DeviceId, deviceId);
            return this.Query(query);
        }
    }
}
